/**
 * @file flash_config.h
 * @brief 
 * @author wangh (wanghuan3037@fiberhome.com)
 * @version 1.0
 * @date 2021-03-02
 * @copyright Copyright (c) 2021  烽火通信
 */
#ifndef __FLASH_CONFIG_H
#define __FLASH_CONFIG_H 
#include "project_config.h"

/* page size for chip flash */
#ifndef FLASH_PAGE_SIZE
#ifdef STM32F10X
#if defined(STM32F10X_LD) || defined(STM32F10X_LD_VL) || defined(STM32F10X_MD) || defined(STM32F10X_MD_VL)
#define FLASH_PAGE_SIZE     1024
#else
#define FLASH_PAGE_SIZE     2048
#endif

#elif defined(GD32F10X)
#if defined(GD32F10x_MD)
#define FLASH_PAGE_SIZE     1024
#else
#define FLASH_PAGE_SIZE     2048    /* @NOTE: 双bank的其中bank0的闪存页大小为2KB，bank1的闪存页大小为4KB */
#endif
#endif
#endif

#ifndef FLASH_START_ADDR
#define FLASH_START_ADDR        ((uint32_t)0x08000000)  ///< flash 起始地址
#endif

#ifndef FLASH_SIZE
#define FLASH_SIZE              (1024 * 1024)           ///< flash 容量（单位字节）+ 96K RAM
#endif

#ifndef FLASH_END_ADDR
#define FLASH_END_ADDR          ((uint32_t)(FLASH_START_ADDR + FLASH_SIZE)) ///< flash 末端地址
#endif


/* Flash划分配置 */
#define BL_START_ADDR       FLASH_START_ADDR
#if IAP_EN
#ifndef BL_SIZE
#define BL_SIZE             (32 * 1024)         ///< 2K的倍数
#endif
#else
#define BL_SIZE             (0 * 1024)          ///< 无bootloader
#endif


#define APP_START_ADDR      ((uint32_t)(BL_START_ADDR + BL_SIZE))
#ifndef APP_SIZE
#define APP_SIZE            (200 * 1024)
#endif




#endif	 // __FLASH_CONFIG_H 

/*********** (C) COPYRIGHT 2021 FiberHome *****END OF FILE****/
